package com.diipo.weibo;


import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost.TabSpec;

public class MainTabs extends TabActivity {
	
	private TabHost tabHost;
	private Context mCtx;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        // Hide title 
        requestWindowFeature( Window.FEATURE_NO_TITLE );
		
        setContentView(R.layout.maintab);
        
        mCtx = this;
        ConfigInfo.setInstanceContext(this);

		tabHost = getTabHost();
		
		Intent home = new Intent(this, Home.class);
		View tabIndicator1 = LayoutInflater.from(mCtx).inflate(R.layout.tab_indicator_layout, tabHost.getTabWidget(), false);
		TextView title = (TextView) tabIndicator1.findViewById(R.id.title);
		title.setText("动态");
		ImageView icon = (ImageView) tabIndicator1.findViewById(R.id.icon);
		icon.setImageResource(R.drawable.home_bg);
		TabSpec homeSpec = tabHost.newTabSpec("tab"+"动态");
		homeSpec.setIndicator(tabIndicator1);
		homeSpec.setContent(home);
		tabHost.addTab(homeSpec);
		
		Intent msg = new Intent(this,  MsgActivity.class);
		View tabIndicator2 = LayoutInflater.from(mCtx).inflate(R.layout.tab_indicator_layout, tabHost.getTabWidget(), false);
		TextView title2 = (TextView) tabIndicator2.findViewById(R.id.title);
		title2.setText("消息");
		ImageView icon2 = (ImageView) tabIndicator2.findViewById(R.id.icon);
		icon2.setImageResource(R.drawable.message_bg);
		TabSpec homeSpec2 = tabHost.newTabSpec("tab"+"消息");
		homeSpec2.setIndicator(tabIndicator2);
		homeSpec2.setContent(msg);
		tabHost.addTab(homeSpec2);
		
		Intent letter = new Intent(this, PrivateLetterActivity.class);
		View tabIndicator3 = LayoutInflater.from(mCtx).inflate(R.layout.tab_indicator_layout, tabHost.getTabWidget(), false);
		TextView title3 = (TextView) tabIndicator3.findViewById(R.id.title);
		title3.setText("私信");
		ImageView icon3 = (ImageView) tabIndicator3.findViewById(R.id.icon);
		icon3.setImageResource(R.drawable.privateletter_bg);
		TabSpec homeSpec3 = tabHost.newTabSpec("tab"+"私信");
		homeSpec3.setIndicator(tabIndicator3);
		homeSpec3.setContent(letter);
		tabHost.addTab(homeSpec3);
		
		Intent contacts = new Intent(this, ContactsActivity.class);
		View tabIndicator4 = LayoutInflater.from(mCtx).inflate(R.layout.tab_indicator_layout, tabHost.getTabWidget(), false);
		TextView title4 = (TextView) tabIndicator4.findViewById(R.id.title);
		title4.setText("联系人");
		ImageView icon4 = (ImageView) tabIndicator4.findViewById(R.id.icon);
		icon4.setImageResource(R.drawable.contacts_bg);
		TabSpec homeSpec4 = tabHost.newTabSpec("tab"+"联系人");
		homeSpec4.setIndicator(tabIndicator4);
		homeSpec4.setContent(contacts);
		tabHost.addTab(homeSpec4);
		
		Intent setting = new Intent(this, SettingActivity.class);
		View tabIndicator5 = LayoutInflater.from(mCtx).inflate(R.layout.tab_indicator_layout, tabHost.getTabWidget(), false);
		TextView title5 = (TextView) tabIndicator5.findViewById(R.id.title);
		title5.setText("设置");
		ImageView icon5 = (ImageView) tabIndicator5.findViewById(R.id.icon);
		icon5.setImageResource(R.drawable.setting_bg);
		TabSpec homeSpec5 = tabHost.newTabSpec("tab"+"设置");
		homeSpec5.setIndicator(tabIndicator5);
		homeSpec5.setContent(setting);
		tabHost.addTab(homeSpec5);
	}
	
	public MainTabs getContext(){
		return (MainTabs) mCtx;
	}
}
